home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_elisp-manual-19.idb / usr / freeware / info / elisp-17.z / elisp-17 (.txt)
GNU Info File  |  1998-05-26  |  50KB  |  914 lines

  1. This is Info file elisp, produced by Makeinfo-1.63 from the input file
  2. elisp.texi.
  3.    This version is the edition 2.4.2 of the GNU Emacs Lisp Reference
  4. Manual.  It corresponds to Emacs Version 19.34.
  5.    Published by the Free Software Foundation 59 Temple Place, Suite 330
  6. Boston, MA  02111-1307  USA
  7.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996 Free Software
  8. Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that the
  14. entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the section entitled "GNU General Public License" is included
  23. exactly as in the original, and provided that the entire resulting
  24. derived work is distributed under the terms of a permission notice
  25. identical to this one.
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public License"
  29. may be included in a translation approved by the Free Software
  30. Foundation instead of in the original English.
  31. File: elisp,  Node: Prefix Keys,  Next: Active Keymaps,  Prev: Inheritance and Keymaps,  Up: Keymaps
  32. Prefix Keys
  33. ===========
  34.    A "prefix key" has an associated keymap that defines what to do with
  35. key sequences that start with the prefix key.  For example, `C-x' is a
  36. prefix key, and it uses a keymap that is also stored in the variable
  37. `ctl-x-map'.  Here is a list of the standard prefix keys of Emacs and
  38. their keymaps:
  39.    * `esc-map' is used for events that follow ESC.  Thus, the global
  40.      definitions of all meta characters are actually found here.  This
  41.      map is also the function definition of `ESC-prefix'.
  42.    * `help-map' is used for events that follow `C-h'.
  43.    * `mode-specific-map' is for events that follow `C-c'.  This map is
  44.      not actually mode specific; its name was chosen to be informative
  45.      for the user in `C-h b' (`display-bindings'), where it describes
  46.      the main use of the `C-c' prefix key.
  47.    * `ctl-x-map' is the map used for events that follow `C-x'.  This
  48.      map is also the function definition of `Control-X-prefix'.
  49.    * `ctl-x-4-map' is used for events that follow `C-x 4'.
  50.    * `ctl-x-5-map' is used for events that follow `C-x 5'.
  51.    * The prefix keys `C-x n', `C-x r' and `C-x a' use keymaps that have
  52.      no special name.
  53.    The binding of a prefix key is the keymap to use for looking up the
  54. events that follow the prefix key.  (It may instead be a symbol whose
  55. function definition is a keymap.  The effect is the same, but the symbol
  56. serves as a name for the prefix key.)  Thus, the binding of `C-x' is
  57. the symbol `Control-X-prefix', whose function definition is the keymap
  58. for `C-x' commands.  (The same keymap is also the value of `ctl-x-map'.)
  59.    Prefix key definitions can appear in any active keymap.  The
  60. definitions of `C-c', `C-x', `C-h' and ESC as prefix keys appear in the
  61. global map, so these prefix keys are always available.  Major and minor
  62. modes can redefine a key as a prefix by putting a prefix key definition
  63. for it in the local map or the minor mode's map.  *Note Active
  64. Keymaps::.
  65.    If a key is defined as a prefix in more than one active map, then its
  66. various definitions are in effect merged: the commands defined in the
  67. minor mode keymaps come first, followed by those in the local map's
  68. prefix definition, and then by those from the global map.
  69.    In the following example, we make `C-p' a prefix key in the local
  70. keymap, in such a way that `C-p' is identical to `C-x'.  Then the
  71. binding for `C-p C-f' is the function `find-file', just like `C-x C-f'.
  72. The key sequence `C-p 6' is not found in any active keymap.
  73.      (use-local-map (make-sparse-keymap))
  74.          => nil
  75.      (local-set-key "\C-p" ctl-x-map)
  76.          => nil
  77.      (key-binding "\C-p\C-f")
  78.          => find-file
  79.      
  80.      (key-binding "\C-p6")
  81.          => nil
  82.  - Function: define-prefix-command SYMBOL
  83.      This function defines SYMBOL as a prefix command: it creates a
  84.      full keymap and stores it as SYMBOL's function definition.
  85.      Storing the symbol as the binding of a key makes the key a prefix
  86.      key that has a name.  The function also sets SYMBOL as a variable,
  87.      to have the keymap as its value.  It returns SYMBOL.
  88.      In Emacs version 18, only the function definition of SYMBOL was
  89.      set, not the value as a variable.
  90. File: elisp,  Node: Active Keymaps,  Next: Key Lookup,  Prev: Prefix Keys,  Up: Keymaps
  91. Active Keymaps
  92. ==============
  93.    Emacs normally contains many keymaps; at any given time, just a few
  94. of them are "active" in that they participate in the interpretation of
  95. user input.  These are the global keymap, the current buffer's local
  96. keymap, and the keymaps of any enabled minor modes.
  97.    The "global keymap" holds the bindings of keys that are defined
  98. regardless of the current buffer, such as `C-f'.  The variable
  99. `global-map' holds this keymap, which is always active.
  100.    Each buffer may have another keymap, its "local keymap", which may
  101. contain new or overriding definitions for keys.  The current buffer's
  102. local keymap is always active except when `overriding-local-map'
  103. overrides it.  Text properties can specify an alternative local map for
  104. certain parts of the buffer; see *Note Special Properties::.
  105.    Each minor mode may have a keymap; if it does, the keymap is active
  106. when the minor mode is enabled.
  107.    The variable `overriding-local-map', if non-`nil', specifies another
  108. local keymap that overrides the buffer's local map and all the minor
  109. mode keymaps.
  110.    All the active keymaps are used together to determine what command to
  111. execute when a key is entered.  Emacs searches these maps one by one, in
  112. order of decreasing precedence, until it finds a binding in one of the
  113. maps.
  114.    Normally, Emacs *first* searches for the key in the minor mode maps
  115. (one map at a time); if they do not supply a binding for the key, Emacs
  116. searches the local map; if that too has no binding, Emacs then searches
  117. the global map.  However, if `overriding-local-map' is non-`nil', Emacs
  118. searches that map first, followed by the global map.
  119.    The procedure for searching a single keymap is called "key lookup";
  120. see *Note Key Lookup::.
  121.    Since every buffer that uses the same major mode normally uses the
  122. same local keymap, you can think of the keymap as local to the mode.  A
  123. change to the local keymap of a buffer (using `local-set-key', for
  124. example) is seen also in the other buffers that share that keymap.
  125.    The local keymaps that are used for Lisp mode, C mode, and several
  126. other major modes exist even if they have not yet been used.  These
  127. local maps are the values of the variables `lisp-mode-map',
  128. `c-mode-map', and so on.  For most other modes, which are less
  129. frequently used, the local keymap is constructed only when the mode is
  130. used for the first time in a session.
  131.    The minibuffer has local keymaps, too; they contain various
  132. completion and exit commands.  *Note Intro to Minibuffers::.
  133.    *Note Standard Keymaps::, for a list of standard keymaps.
  134.  - Variable: global-map
  135.      This variable contains the default global keymap that maps Emacs
  136.      keyboard input to commands.  The global keymap is normally this
  137.      keymap.  The default global keymap is a full keymap that binds
  138.      `self-insert-command' to all of the printing characters.
  139.      It is normal practice to change the bindings in the global map,
  140.      but you should not assign this variable any value other than the
  141.      keymap it starts out with.
  142.  - Function: current-global-map
  143.      This function returns the current global keymap.  This is the same
  144.      as the value of `global-map' unless you change one or the other.
  145.           (current-global-map)
  146.           => (keymap [set-mark-command beginning-of-line ...
  147.                       delete-backward-char])
  148.  - Function: current-local-map
  149.      This function returns the current buffer's local keymap, or `nil'
  150.      if it has none.  In the following example, the keymap for the
  151.      `*scratch*' buffer (using Lisp Interaction mode) is a sparse keymap
  152.      in which the entry for ESC, ASCII code 27, is another sparse
  153.      keymap.
  154.           (current-local-map)
  155.           => (keymap
  156.               (10 . eval-print-last-sexp)
  157.               (9 . lisp-indent-line)
  158.               (127 . backward-delete-char-untabify)
  159.               (27 keymap
  160.                   (24 . eval-defun)
  161.                   (17 . indent-sexp)))
  162.  - Function: current-minor-mode-maps
  163.      This function returns a list of the keymaps of currently enabled
  164.      minor modes.
  165.  - Function: use-global-map KEYMAP
  166.      This function makes KEYMAP the new current global keymap.  It
  167.      returns `nil'.
  168.      It is very unusual to change the global keymap.
  169.  - Function: use-local-map KEYMAP
  170.      This function makes KEYMAP the new local keymap of the current
  171.      buffer.  If KEYMAP is `nil', then the buffer has no local keymap.
  172.      `use-local-map' returns `nil'.  Most major mode commands use this
  173.      function.
  174.  - Variable: minor-mode-map-alist
  175.      This variable is an alist describing keymaps that may or may not be
  176.      active according to the values of certain variables.  Its elements
  177.      look like this:
  178.           (VARIABLE . KEYMAP)
  179.      The keymap KEYMAP is active whenever VARIABLE has a non-`nil'
  180.      value.  Typically VARIABLE is the variable that enables or
  181.      disables a minor mode.  *Note Keymaps and Minor Modes::.
  182.      Note that elements of `minor-mode-map-alist' do not have the same
  183.      structure as elements of `minor-mode-alist'.  The map must be the
  184.      CDR of the element; a list with the map as the second element will
  185.      not do.
  186.      What's more, the keymap itself must appear in the CDR.  It does not
  187.      work to store a variable in the CDR and make the map the value of
  188.      that variable.
  189.      When more than one minor mode keymap is active, their order of
  190.      priority is the order of `minor-mode-map-alist'.  But you should
  191.      design minor modes so that they don't interfere with each other.
  192.      If you do this properly, the order will not matter.
  193.      See also `minor-mode-key-binding', above.  See *Note Keymaps and
  194.      Minor Modes::, for more information about minor modes.
  195.  - Variable: overriding-local-map
  196.      If non-`nil', this variable holds a keymap to use instead of the
  197.      buffer's local keymap and instead of all the minor mode keymaps.
  198.      This keymap, if any, overrides all other maps that would have been
  199.      active, except for the current global map.
  200.  - Variable: overriding-terminal-local-map
  201.      If non-`nil', this variable holds a keymap to use instead of
  202.      `overriding-local-map', the buffer's local keymap and all the minor
  203.      mode keymaps.
  204.      This variable is always local to the current terminal and cannot be
  205.      buffer-local.  *Note Multiple Displays::.  It is used to implement
  206.      incremental search mode.
  207.  - Variable: overriding-local-map-menu-flag
  208.      If this variable is non-`nil', the value of `overriding-local-map'
  209.      or `overriding-terminal-local-map' can affect the display of the
  210.      menu bar.  The default value is `nil', so those map variables have
  211.      no effect on the menu bar.
  212.      Note that these two map variables do affect the execution of key
  213.      sequences entered using the menu bar, even if they do not affect
  214.      the menu bar display.  So if a menu bar key sequence comes in, you
  215.      should clear the variables before looking up and executing that
  216.      key sequence.  Modes that use the variables would typically do
  217.      this anyway; normally they respond to events that they do not
  218.      handle by "unreading" them and exiting.
  219. File: elisp,  Node: Key Lookup,  Next: Functions for Key Lookup,  Prev: Active Keymaps,  Up: Keymaps
  220. Key Lookup
  221. ==========
  222.    "Key lookup" is the process of finding the binding of a key sequence
  223. from a given keymap.  Actual execution of the binding is not part of
  224. key lookup.
  225.    Key lookup uses just the event type of each event in the key
  226. sequence; the rest of the event is ignored.  In fact, a key sequence
  227. used for key lookup may designate mouse events with just their types
  228. (symbols) instead of with entire mouse events (lists).  *Note Input
  229. Events::.  Such a pseudo-key-sequence is insufficient for
  230. `command-execute', but it is sufficient for looking up or rebinding a
  231.    When the key sequence consists of multiple events, key lookup
  232. processes the events sequentially: the binding of the first event is
  233. found, and must be a keymap; then the second event's binding is found in
  234. that keymap, and so on until all the events in the key sequence are used
  235. up.  (The binding thus found for the last event may or may not be a
  236. keymap.)  Thus, the process of key lookup is defined in terms of a
  237. simpler process for looking up a single event in a keymap.  How that is
  238. done depends on the type of object associated with the event in that
  239. keymap.
  240.    Let's use the term "keymap entry" to describe the value found by
  241. looking up an event type in a keymap.  (This doesn't include the item
  242. string and other extra elements in menu key bindings because
  243. `lookup-key' and other key lookup functions don't include them in the
  244. returned value.)  While any Lisp object may be stored in a keymap as a
  245. keymap entry, not all make sense for key lookup.  Here is a list of the
  246. meaningful kinds of keymap entries:
  247. `nil'
  248.      `nil' means that the events used so far in the lookup form an
  249.      undefined key.  When a keymap fails to mention an event type at
  250.      all, and has no default binding, that is equivalent to a binding
  251.      of `nil' for that event type.
  252. KEYMAP
  253.      The events used so far in the lookup form a prefix key.  The next
  254.      event of the key sequence is looked up in KEYMAP.
  255. COMMAND
  256.      The events used so far in the lookup form a complete key, and
  257.      COMMAND is its binding.  *Note What Is a Function::.
  258. ARRAY
  259.      The array (either a string or a vector) is a keyboard macro.  The
  260.      events used so far in the lookup form a complete key, and the
  261.      array is its binding.  See *Note Keyboard Macros::, for more
  262.      information.
  263.      The meaning of a list depends on the types of the elements of the
  264.      list.
  265.         * If the CAR of LIST is the symbol `keymap', then the list is a
  266.           keymap, and is treated as a keymap (see above).
  267.         * If the CAR of LIST is `lambda', then the list is a lambda
  268.           expression.  This is presumed to be a command, and is treated
  269.           as such (see above).
  270.         * If the CAR of LIST is a keymap and the CDR is an event type,
  271.           then this is an "indirect entry":
  272.                (OTHERMAP . OTHERTYPE)
  273.           When key lookup encounters an indirect entry, it looks up
  274.           instead the binding of OTHERTYPE in OTHERMAP and uses that.
  275.           This feature permits you to define one key as an alias for
  276.           another key.  For example, an entry whose CAR is the keymap
  277.           called `esc-map' and whose CDR is 32 (the code for SPC)
  278.           means, "Use the global binding of `Meta-SPC', whatever that
  279.           may be."
  280. SYMBOL
  281.      The function definition of SYMBOL is used in place of SYMBOL.  If
  282.      that too is a symbol, then this process is repeated, any number of
  283.      times.  Ultimately this should lead to an object that is a keymap,
  284.      a command or a keyboard macro.  A list is allowed if it is a
  285.      keymap or a command, but indirect entries are not understood when
  286.      found via symbols.
  287.      Note that keymaps and keyboard macros (strings and vectors) are not
  288.      valid functions, so a symbol with a keymap, string, or vector as
  289.      its function definition is invalid as a function.  It is, however,
  290.      valid as a key binding.  If the definition is a keyboard macro,
  291.      then the symbol is also valid as an argument to `command-execute'
  292.      (*note Interactive Call::.).
  293.      The symbol `undefined' is worth special mention: it means to treat
  294.      the key as undefined.  Strictly speaking, the key is defined, and
  295.      its binding is the command `undefined'; but that command does the
  296.      same thing that is done automatically for an undefined key: it
  297.      rings the bell (by calling `ding') but does not signal an error.
  298.      `undefined' is used in local keymaps to override a global key
  299.      binding and make the key "undefined" locally.  A local binding of
  300.      `nil' would fail to do this because it would not override the
  301.      global binding.
  302. ANYTHING ELSE
  303.      If any other type of object is found, the events used so far in the
  304.      lookup form a complete key, and the object is its binding, but the
  305.      binding is not executable as a command.
  306.    In short, a keymap entry may be a keymap, a command, a keyboard
  307. macro, a symbol that leads to one of them, or an indirection or `nil'.
  308. Here is an example of a sparse keymap with two characters bound to
  309. commands and one bound to another keymap.  This map is the normal value
  310. of `emacs-lisp-mode-map'.  Note that 9 is the code for TAB, 127 for
  311. DEL, 27 for ESC, 17 for `C-q' and 24 for `C-x'.
  312.      (keymap (9 . lisp-indent-line)
  313.              (127 . backward-delete-char-untabify)
  314.              (27 keymap (17 . indent-sexp) (24 . eval-defun)))
  315. File: elisp,  Node: Functions for Key Lookup,  Next: Changing Key Bindings,  Prev: Key Lookup,  Up: Keymaps
  316. Functions for Key Lookup
  317. ========================
  318.    Here are the functions and variables pertaining to key lookup.
  319.  - Function: lookup-key KEYMAP KEY &optional ACCEPT-DEFAULTS
  320.      This function returns the definition of KEY in KEYMAP.  If the
  321.      string or vector KEY is not a valid key sequence according to the
  322.      prefix keys specified in KEYMAP (which means it is "too long" and
  323.      has extra events at the end), then the value is a number, the
  324.      number of events at the front of KEY that compose a complete key.
  325.      If ACCEPT-DEFAULTS is non-`nil', then `lookup-key' considers
  326.      default bindings as well as bindings for the specific events in
  327.      KEY.  Otherwise, `lookup-key' reports only bindings for the
  328.      specific sequence KEY, ignoring default bindings except when you
  329.      explicitly ask about them.  (To do this, supply `t' as an element
  330.      of KEY; see *Note Format of Keymaps::.)
  331.      All the other functions described in this chapter that look up
  332.      keys use `lookup-key'.
  333.           (lookup-key (current-global-map) "\C-x\C-f")
  334.               => find-file
  335.           (lookup-key (current-global-map) "\C-x\C-f12345")
  336.               => 2
  337.      If KEY contains a meta character, that character is implicitly
  338.      replaced by a two-character sequence: the value of
  339.      `meta-prefix-char', followed by the corresponding non-meta
  340.      character.  Thus, the first example below is handled by conversion
  341.      into the second example.
  342.           (lookup-key (current-global-map) "\M-f")
  343.               => forward-word
  344.           (lookup-key (current-global-map) "\ef")
  345.               => forward-word
  346.      Unlike `read-key-sequence', this function does not modify the
  347.      specified events in ways that discard information (*note Key
  348.      Sequence Input::.).  In particular, it does not convert letters to
  349.      lower case and it does not change drag events to clicks.
  350.  - Command: undefined
  351.      Used in keymaps to undefine keys.  It calls `ding', but does not
  352.      cause an error.
  353.  - Function: key-binding KEY &optional ACCEPT-DEFAULTS
  354.      This function returns the binding for KEY in the current keymaps,
  355.      trying all the active keymaps.  The result is `nil' if KEY is
  356.      undefined in the keymaps.
  357.      The argument ACCEPT-DEFAULTS controls checking for default
  358.      bindings, as in `lookup-key' (above).
  359.      An error is signaled if KEY is not a string or a vector.
  360.           (key-binding "\C-x\C-f")
  361.               => find-file
  362.  - Function: local-key-binding KEY &optional ACCEPT-DEFAULTS
  363.      This function returns the binding for KEY in the current local
  364.      keymap, or `nil' if it is undefined there.
  365.      The argument ACCEPT-DEFAULTS controls checking for default
  366.      bindings, as in `lookup-key' (above).
  367.  - Function: global-key-binding KEY &optional ACCEPT-DEFAULTS
  368.      This function returns the binding for command KEY in the current
  369.      global keymap, or `nil' if it is undefined there.
  370.      The argument ACCEPT-DEFAULTS controls checking for default
  371.      bindings, as in `lookup-key' (above).
  372.  - Function: minor-mode-key-binding KEY &optional ACCEPT-DEFAULTS
  373.      This function returns a list of all the active minor mode bindings
  374.      of KEY.  More precisely, it returns an alist of pairs `(MODENAME .
  375.      BINDING)', where MODENAME is the variable that enables the minor
  376.      mode, and BINDING is KEY's binding in that mode.  If KEY has no
  377.      minor-mode bindings, the value is `nil'.
  378.      If the first binding is not a prefix command, all subsequent
  379.      bindings from other minor modes are omitted, since they would be
  380.      completely shadowed.  Similarly, the list omits non-prefix
  381.      bindings that follow prefix bindings.
  382.      The argument ACCEPT-DEFAULTS controls checking for default
  383.      bindings, as in `lookup-key' (above).
  384.  - Variable: meta-prefix-char
  385.      This variable is the meta-prefix character code.  It is used when
  386.      translating a meta character to a two-character sequence so it can
  387.      be looked up in a keymap.  For useful results, the value should be
  388.      a prefix event (*note Prefix Keys::.).  The default value is 27,
  389.      which is the ASCII code for ESC.
  390.      As long as the value of `meta-prefix-char' remains 27, key lookup
  391.      translates `M-b' into `ESC b', which is normally defined as the
  392.      `backward-word' command.  However, if you set `meta-prefix-char'
  393.      to 24, the code for `C-x', then Emacs will translate `M-b' into
  394.      `C-x b', whose standard binding is the `switch-to-buffer' command.
  395.           meta-prefix-char                    ; The default value.
  396.                => 27
  397.           (key-binding "\M-b")
  398.                => backward-word
  399.           ?\C-x                               ; The print representation
  400.                => 24                          ;   of a character.
  401.           (setq meta-prefix-char 24)
  402.                => 24
  403.           (key-binding "\M-b")
  404.                => switch-to-buffer            ; Now, typing `M-b' is
  405.                                               ;   like typing `C-x b'.
  406.           
  407.           (setq meta-prefix-char 27)          ; Avoid confusion!
  408.                => 27                          ; Restore the default value!
  409. File: elisp,  Node: Changing Key Bindings,  Next: Key Binding Commands,  Prev: Functions for Key Lookup,  Up: Keymaps
  410. Changing Key Bindings
  411. =====================
  412.    The way to rebind a key is to change its entry in a keymap.  If you
  413. change a binding in the global keymap, the change is effective in all
  414. buffers (though it has no direct effect in buffers that shadow the
  415. global binding with a local one).  If you change the current buffer's
  416. local map, that usually affects all buffers using the same major mode.
  417. The `global-set-key' and `local-set-key' functions are convenient
  418. interfaces for these operations (*note Key Binding Commands::.).  You
  419. can also use `define-key', a more general function; then you must
  420. specify explicitly the map to change.
  421.    In writing the key sequence to rebind, it is good to use the special
  422. escape sequences for control and meta characters (*note String Type::.).
  423. The syntax `\C-' means that the following character is a control
  424. character and `\M-' means that the following character is a meta
  425. character.  Thus, the string `"\M-x"' is read as containing a single
  426. `M-x', `"\C-f"' is read as containing a single `C-f', and `"\M-\C-x"'
  427. and `"\C-\M-x"' are both read as containing a single `C-M-x'.  You can
  428. also use this escape syntax in vectors, as well as others that aren't
  429. allowed in strings; one example is `[?\C-\H-x home]'.  *Note Character
  430. Type::.
  431.    The key definition and lookup functions accept an alternate syntax
  432. for event types in a key sequence that is a vector: you can use a list
  433. containing modifier names plus one base event (a character or function
  434. key name).  For example, `(control ?a)' is equivalent to `?\C-a' and
  435. `(hyper control left)' is equivalent to `C-H-left'.
  436.    One advantage of using a list to represent the event type is that the
  437. precise numeric codes for the modifier bits don't appear in compiled
  438. files.
  439.    For the functions below, an error is signaled if KEYMAP is not a
  440. keymap or if KEY is not a string or vector representing a key sequence.
  441. You can use event types (symbols) as shorthand for events that are
  442. lists.
  443.  - Function: define-key KEYMAP KEY BINDING
  444.      This function sets the binding for KEY in KEYMAP.  (If KEY is more
  445.      than one event long, the change is actually made in another keymap
  446.      reached from KEYMAP.)  The argument BINDING can be any Lisp
  447.      object, but only certain types are meaningful.  (For a list of
  448.      meaningful types, see *Note Key Lookup::.) The value returned by
  449.      `define-key' is BINDING.
  450.      Every prefix of KEY must be a prefix key (i.e., bound to a keymap)
  451.      or undefined; otherwise an error is signaled.
  452.      If some prefix of KEY is undefined, then `define-key' defines it
  453.      as a prefix key so that the rest of KEY may be defined as
  454.      specified.
  455.    Here is an example that creates a sparse keymap and makes a number of
  456. bindings in it:
  457.      (setq map (make-sparse-keymap))
  458.          => (keymap)
  459.      (define-key map "\C-f" 'forward-char)
  460.          => forward-char
  461.      map
  462.          => (keymap (6 . forward-char))
  463.      ;; Build sparse submap for `C-x' and bind `f' in that.
  464.      (define-key map "\C-xf" 'forward-word)
  465.          => forward-word
  466.      map
  467.      => (keymap
  468.          (24 keymap                ; `C-x'
  469.              (102 . forward-word)) ;      `f'
  470.          (6 . forward-char))       ; `C-f'
  471.      ;; Bind `C-p' to the `ctl-x-map'.
  472.      (define-key map "\C-p" ctl-x-map)
  473.      ;; `ctl-x-map'
  474.      => [nil ... find-file ... backward-kill-sentence]
  475.      ;; Bind `C-f' to `foo' in the `ctl-x-map'.
  476.      (define-key map "\C-p\C-f" 'foo)
  477.      => 'foo
  478.      map
  479.      => (keymap     ; Note `foo' in `ctl-x-map'.
  480.          (16 keymap [nil ... foo ... backward-kill-sentence])
  481.          (24 keymap
  482.              (102 . forward-word))
  483.          (6 . forward-char))
  484. Note that storing a new binding for `C-p C-f' actually works by
  485. changing an entry in `ctl-x-map', and this has the effect of changing
  486. the bindings of both `C-p C-f' and `C-x C-f' in the default global map.
  487.  - Function: substitute-key-definition OLDDEF NEWDEF KEYMAP &optional
  488.           OLDMAP
  489.      This function replaces OLDDEF with NEWDEF for any keys in KEYMAP
  490.      that were bound to OLDDEF.  In other words, OLDDEF is replaced
  491.      with NEWDEF wherever it appears.  The function returns `nil'.
  492.      For example, this redefines `C-x C-f', if you do it in an Emacs
  493.      with standard bindings:
  494.           (substitute-key-definition
  495.            'find-file 'find-file-read-only (current-global-map))
  496.      If OLDMAP is non-`nil', then its bindings determine which keys to
  497.      rebind.  The rebindings still happen in KEYMAP, not in OLDMAP.
  498.      Thus, you can change one map under the control of the bindings in
  499.      another.  For example,
  500.           (substitute-key-definition
  501.             'delete-backward-char 'my-funny-delete
  502.             my-map global-map)
  503.      puts the special deletion command in `my-map' for whichever keys
  504.      are globally bound to the standard deletion command.
  505.      Here is an example showing a keymap before and after substitution:
  506.           (setq map '(keymap
  507.                       (?1 . olddef-1)
  508.                       (?2 . olddef-2)
  509.                       (?3 . olddef-1)))
  510.           => (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1))
  511.           (substitute-key-definition 'olddef-1 'newdef map)
  512.           => nil
  513.           map
  514.           => (keymap (49 . newdef) (50 . olddef-2) (51 . newdef))
  515.  - Function: suppress-keymap KEYMAP &optional NODIGITS
  516.      This function changes the contents of the full keymap KEYMAP by
  517.      making all the printing characters undefined.  More precisely, it
  518.      binds them to the command `undefined'.  This makes ordinary
  519.      insertion of text impossible.  `suppress-keymap' returns `nil'.
  520.      If NODIGITS is `nil', then `suppress-keymap' defines digits to run
  521.      `digit-argument', and `-' to run `negative-argument'.  Otherwise
  522.      it makes them undefined like the rest of the printing characters.
  523.      The `suppress-keymap' function does not make it impossible to
  524.      modify a buffer, as it does not suppress commands such as `yank'
  525.      and `quoted-insert'.  To prevent any modification of a buffer, make
  526.      it read-only (*note Read Only Buffers::.).
  527.      Since this function modifies KEYMAP, you would normally use it on
  528.      a newly created keymap.  Operating on an existing keymap that is
  529.      used for some other purpose is likely to cause trouble; for
  530.      example, suppressing `global-map' would make it impossible to use
  531.      most of Emacs.
  532.      Most often, `suppress-keymap' is used to initialize local keymaps
  533.      of modes such as Rmail and Dired where insertion of text is not
  534.      desirable and the buffer is read-only.  Here is an example taken
  535.      from the file `emacs/lisp/dired.el', showing how the local keymap
  536.      for Dired mode is set up:
  537.           ...
  538.             (setq dired-mode-map (make-keymap))
  539.             (suppress-keymap dired-mode-map)
  540.             (define-key dired-mode-map "r" 'dired-rename-file)
  541.             (define-key dired-mode-map "\C-d" 'dired-flag-file-deleted)
  542.             (define-key dired-mode-map "d" 'dired-flag-file-deleted)
  543.             (define-key dired-mode-map "v" 'dired-view-file)
  544.             (define-key dired-mode-map "e" 'dired-find-file)
  545.             (define-key dired-mode-map "f" 'dired-find-file)
  546.             ...
  547. File: elisp,  Node: Key Binding Commands,  Next: Scanning Keymaps,  Prev: Changing Key Bindings,  Up: Keymaps
  548. Commands for Binding Keys
  549. =========================
  550.    This section describes some convenient interactive interfaces for
  551. changing key bindings.  They work by calling `define-key'.
  552.    People often use `global-set-key' in their `.emacs' file for simple
  553. customization.  For example,
  554.      (global-set-key "\C-x\C-\\" 'next-line)
  555.      (global-set-key [?\C-x ?\C-\\] 'next-line)
  556.      (global-set-key [(control ?x) (control ?\\)] 'next-line)
  557. redefines `C-x C-\' to move down a line.
  558.      (global-set-key [M-mouse-1] 'mouse-set-point)
  559. redefines the first (leftmost) mouse button, typed with the Meta key, to
  560. set point where you click.
  561.  - Command: global-set-key KEY DEFINITION
  562.      This function sets the binding of KEY in the current global map to
  563.      DEFINITION.
  564.           (global-set-key KEY DEFINITION)
  565.           ==
  566.           (define-key (current-global-map) KEY DEFINITION)
  567.  - Command: global-unset-key KEY
  568.      This function removes the binding of KEY from the current global
  569.      map.
  570.      One use of this function is in preparation for defining a longer
  571.      key that uses KEY as a prefix--which would not be allowed if KEY
  572.      has a non-prefix binding.  For example:
  573.           (global-unset-key "\C-l")
  574.               => nil
  575.           (global-set-key "\C-l\C-l" 'redraw-display)
  576.               => nil
  577.      This function is implemented simply using `define-key':
  578.           (global-unset-key KEY)
  579.           ==
  580.           (define-key (current-global-map) KEY nil)
  581.  - Command: local-set-key KEY DEFINITION
  582.      This function sets the binding of KEY in the current local keymap
  583.      to DEFINITION.
  584.           (local-set-key KEY DEFINITION)
  585.           ==
  586.           (define-key (current-local-map) KEY DEFINITION)
  587.  - Command: local-unset-key KEY
  588.      This function removes the binding of KEY from the current local
  589.      map.
  590.           (local-unset-key KEY)
  591.           ==
  592.           (define-key (current-local-map) KEY nil)
  593. File: elisp,  Node: Scanning Keymaps,  Next: Menu Keymaps,  Prev: Key Binding Commands,  Up: Keymaps
  594. Scanning Keymaps
  595. ================
  596.    This section describes functions used to scan all the current keymaps
  597. for the sake of printing help information.
  598.  - Function: accessible-keymaps KEYMAP &optional PREFIX
  599.      This function returns a list of all the keymaps that can be
  600.      accessed (via prefix keys) from KEYMAP.  The value is an
  601.      association list with elements of the form `(KEY . MAP)', where
  602.      KEY is a prefix key whose definition in KEYMAP is MAP.
  603.      The elements of the alist are ordered so that the KEY increases in
  604.      length.  The first element is always `("" . KEYMAP)', because the
  605.      specified keymap is accessible from itself with a prefix of no
  606.      events.
  607.      If PREFIX is given, it should be a prefix key sequence; then
  608.      `accessible-keymaps' includes only the submaps whose prefixes start
  609.      with PREFIX.  These elements look just as they do in the value of
  610.      `(accessible-keymaps)'; the only difference is that some elements
  611.      are omitted.
  612.      In the example below, the returned alist indicates that the key
  613.      ESC, which is displayed as `^[', is a prefix key whose definition
  614.      is the sparse keymap `(keymap (83 . center-paragraph) (115 .
  615.      foo))'.
  616.           (accessible-keymaps (current-local-map))
  617.           =>(("" keymap
  618.                 (27 keymap   ; Note this keymap for ESC is repeated below.
  619.                     (83 . center-paragraph)
  620.                     (115 . center-line))
  621.                 (9 . tab-to-tab-stop))
  622.           ("^[" keymap
  623.               (83 . center-paragraph)
  624.               (115 . foo)))
  625.      In the following example, `C-h' is a prefix key that uses a sparse
  626.      keymap starting with `(keymap (118 . describe-variable)...)'.
  627.      Another prefix, `C-x 4', uses a keymap which is also the value of
  628.      the variable `ctl-x-4-map'.  The event `mode-line' is one of
  629.      several dummy events used as prefixes for mouse actions in special
  630.      parts of a window.
  631.           (accessible-keymaps (current-global-map))
  632.           => (("" keymap [set-mark-command beginning-of-line ...
  633.                              delete-backward-char])
  634.           ("^H" keymap (118 . describe-variable) ...
  635.                (8 . help-for-help))
  636.           ("^X" keymap [x-flush-mouse-queue ...
  637.                backward-kill-sentence])
  638.           ("^[" keymap [mark-sexp backward-sexp ...
  639.                backward-kill-word])
  640.               ("^X4" keymap (15 . display-buffer) ...)
  641.           ([mode-line] keymap
  642.                (S-mouse-2 . mouse-split-window-horizontally) ...))
  643.      These are not all the keymaps you would see in an actual case.
  644.  - Function: where-is-internal COMMAND &optional KEYMAP FIRSTONLY
  645.           NOINDIRECT
  646.      This function returns a list of key sequences (of any length) that
  647.      are bound to COMMAND in a set of keymaps.
  648.      The argument COMMAND can be any object; it is compared with all
  649.      keymap entries using `eq'.
  650.      If KEYMAP is `nil', then the maps used are the current active
  651.      keymaps, disregarding `overriding-local-map' (that is, pretending
  652.      its value is `nil').  If KEYMAP is non-`nil', then the maps
  653.      searched are KEYMAP and the global keymap.
  654.      Usually it's best to use `overriding-local-map' as the expression
  655.      for KEYMAP.  Then `where-is-internal' searches precisely the
  656.      keymaps that are active.  To search only the global map, pass
  657.      `(keymap)' (an empty keymap) as KEYMAP.
  658.      If FIRSTONLY is `non-ascii', then the value is a single string
  659.      representing the first key sequence found, rather than a list of
  660.      all possible key sequences.  If FIRSTONLY is `t', then the value
  661.      is the first key sequence, except that key sequences consisting
  662.      entirely of ASCII characters (or meta variants of ASCII
  663.      characters) are preferred to all other key sequences.
  664.      If NOINDIRECT is non-`nil', `where-is-internal' doesn't follow
  665.      indirect keymap bindings.  This makes it possible to search for an
  666.      indirect definition itself.
  667.      This function is used by `where-is' (*note Help: (emacs)Help.).
  668.           (where-is-internal 'describe-function)
  669.               => ("\^hf" "\^hd")
  670.  - Command: describe-bindings PREFIX
  671.      This function creates a listing of all defined keys and their
  672.      definitions.  It writes the listing in a buffer named `*Help*' and
  673.      displays it in a window.
  674.      If PREFIX is non-`nil', it should be a prefix key; then the
  675.      listing includes only keys that start with PREFIX.
  676.      The listing describes meta characters as ESC followed by the
  677.      corresponding non-meta character.
  678.      When several characters with consecutive ASCII codes have the same
  679.      definition, they are shown together, as `FIRSTCHAR..LASTCHAR'.  In
  680.      this instance, you need to know the ASCII codes to understand
  681.      which characters this means.  For example, in the default global
  682.      map, the characters `SPC .. ~' are described by a single line.
  683.      SPC is ASCII 32, `~' is ASCII 126, and the characters between them
  684.      include all the normal printing characters, (e.g., letters,
  685.      digits, punctuation, etc.); all these characters are bound to
  686.      `self-insert-command'.
  687. File: elisp,  Node: Menu Keymaps,  Prev: Scanning Keymaps,  Up: Keymaps
  688. Menu Keymaps
  689. ============
  690.    A keymap can define a menu as well as bindings for keyboard keys and
  691. mouse button.  Menus are usually actuated with the mouse, but they can
  692. work with the keyboard also.
  693. * Menu:
  694. * Defining Menus::        How to make a keymap that defines a menu.
  695. * Mouse Menus::            How users actuate the menu with the mouse.
  696. * Keyboard Menus::        How they actuate it with the keyboard.
  697. * Menu Example::        Making a simple menu.
  698. * Menu Bar::            How to customize the menu bar.
  699. * Modifying Menus::             How to add new items to a menu.
  700. File: elisp,  Node: Defining Menus,  Next: Mouse Menus,  Up: Menu Keymaps
  701. Defining Menus
  702. --------------
  703.    A keymap is suitable for menu use if it has an "overall prompt
  704. string", which is a string that appears as an element of the keymap.
  705. (*Note Format of Keymaps::.)  The string should describe the purpose of
  706. the menu.  The easiest way to construct a keymap with a prompt string is
  707. to specify the string as an argument when you call `make-keymap' or
  708. `make-sparse-keymap' (*note Creating Keymaps::.).
  709.    The order of items in the menu is the same as the order of bindings
  710. in the keymap.  Since `define-key' puts new bindings at the front, you
  711. should define the menu items starting at the bottom of the menu and
  712. moving to the top, if you care about the order.  When you add an item to
  713. an existing menu, you can specify its position in the menu using
  714. `define-key-after' (*note Modifying Menus::.).
  715.    The individual bindings in the menu keymap should have item strings;
  716. these strings become the items displayed in the menu.  A binding with
  717. an item string looks like this:
  718.      (STRING . REAL-BINDING)
  719.    The item string for a binding should be short--one or two words.  It
  720. should describe the action of the command it corresponds to.
  721.    You can also supply a second string, called the help string, as
  722. follows:
  723.      (STRING HELP-STRING . REAL-BINDING)
  724.    Currently Emacs does not actually use HELP-STRING; it knows only how
  725. to ignore HELP-STRING in order to extract REAL-BINDING.  In the future
  726. we may use HELP-STRING as extended documentation for the menu item,
  727. available on request.
  728.    As far as `define-key' is concerned, STRING and HELP-STRING are part
  729. of the event's binding.  However, `lookup-key' returns just
  730. REAL-BINDING, and only REAL-BINDING is used for executing the key.
  731.    If REAL-BINDING is `nil', then STRING appears in the menu but cannot
  732. be selected.
  733.    If REAL-BINDING is a symbol and has a non-`nil' `menu-enable'
  734. property, that property is an expression that controls whether the menu
  735. item is enabled.  Every time the keymap is used to display a menu,
  736. Emacs evaluates the expression, and it enables the menu item only if
  737. the expression's value is non-`nil'.  When a menu item is disabled, it
  738. is displayed in a "fuzzy" fashion, and cannot be selected with the
  739. mouse.
  740.    The menu bar does not recalculate which items are enabled every time
  741. you look at a menu.  This is because the X toolkit requires the whole
  742. tree of menus in advance.  To force recalculation of the menu bar, call
  743. `force-mode-line-update' (*note Mode Line Format::.).
  744.    You've probably noticed that menu items show the equivalent keyboard
  745. key sequence (if any) to invoke the same command.  To save time on
  746. recalculation, menu display caches this information in a sublist in the
  747. binding, like this:
  748.      (STRING [HELP-STRING] (KEY-BINDING-DATA) . REAL-BINDING)
  749.    Don't put these sublists in the menu item yourself; menu display
  750. calculates them automatically.  Don't add keyboard equivalents to the
  751. item strings in a mouse menu, since that is redundant.
  752.    Sometimes it is useful to make menu items that use the "same" command
  753. but with different enable conditions.  You can do this by defining alias
  754. commands.  Here's an example that makes two aliases for
  755. `toggle-read-only' and gives them different enable conditions:
  756.      (defalias 'make-read-only 'toggle-read-only)
  757.      (put 'make-read-only 'menu-enable '(not buffer-read-only))
  758.      (defalias 'make-writable 'toggle-read-only)
  759.      (put 'make-writable 'menu-enable 'buffer-read-only)
  760.    When using aliases in menus, often it is useful to display the
  761. equivalent key bindings for the "real" command name, not the aliases
  762. (which typically don't have any key bindings except for the menu
  763. itself).  To request this, give the alias symbol a non-`nil'
  764. `menu-alias' property.  Thus,
  765.      (put 'make-read-only 'menu-alias t)
  766.      (put 'make-writable 'menu-alias t)
  767. causes menu items for `make-read-only' and `make-writable' to show the
  768. keyboard bindings for `toggle-read-only'.
  769. File: elisp,  Node: Mouse Menus,  Next: Keyboard Menus,  Prev: Defining Menus,  Up: Menu Keymaps
  770. Menus and the Mouse
  771. -------------------
  772.    The way to make a menu keymap produce a menu is to make it the
  773. definition of a prefix key.
  774.    If the prefix key ends with a mouse event, Emacs handles the menu
  775. keymap by popping up a visible menu, so that the user can select a
  776. choice with the mouse.  When the user clicks on a menu item, the event
  777. generated is whatever character or symbol has the binding that brought
  778. about that menu item.  (A menu item may generate a series of events if
  779. the menu has multiple levels or comes from the menu bar.)
  780.    It's often best to use a button-down event to trigger the menu.  Then
  781. the user can select a menu item by releasing the button.
  782.    A single keymap can appear as multiple menu panes, if you explicitly
  783. arrange for this.  The way to do this is to make a keymap for each pane,
  784. then create a binding for each of those maps in the main keymap of the
  785. menu.  Give each of these bindings an item string that starts with `@'.
  786. The rest of the item string becomes the name of the pane.  See the
  787. file `lisp/mouse.el' for an example of this.  Any ordinary bindings
  788. with `@'-less item strings are grouped into one pane, which appears
  789. along with the other panes explicitly created for the submaps.
  790.    X toolkit menus don't have panes; instead, they can have submenus.
  791. Every nested keymap becomes a submenu, whether the item string starts
  792. with `@' or not.  In a toolkit version of Emacs, the only thing special
  793. about `@' at the beginning of an item string is that the `@' doesn't
  794. appear in the menu item.
  795.    You can also get multiple panes from separate keymaps.  The full
  796. definition of a prefix key always comes from merging the definitions
  797. supplied by the various active keymaps (minor mode, local, and global).
  798. When more than one of these keymaps is a menu, each of them makes a
  799. separate pane or panes.  *Note Active Keymaps::.
  800.    In toolkit versions of Emacs, menus don't have panes, so submenus are
  801. used to represent the separate keymaps.  Each keymap's contribution
  802. becomes one submenu.
  803.    A Lisp program can explicitly pop up a menu and receive the user's
  804. choice.  You can use keymaps for this also.  *Note Pop-Up Menus::.
  805. File: elisp,  Node: Keyboard Menus,  Next: Menu Example,  Prev: Mouse Menus,  Up: Menu Keymaps
  806. Menus and the Keyboard
  807. ----------------------
  808.    When a prefix key ending with a keyboard event (a character or
  809. function key) has a definition that is a menu keymap, the user can use
  810. the keyboard to choose a menu item.
  811.    Emacs displays the menu alternatives (the item strings of the
  812. bindings) in the echo area.  If they don't all fit at once, the user
  813. can type SPC to see the next line of alternatives.  Successive uses of
  814. SPC eventually get to the end of the menu and then cycle around to the
  815. beginning.  (The variable `menu-prompt-more-char' specifies which
  816. character is used for this; SPC is the default.)
  817.    When the user has found the desired alternative from the menu, he or
  818. she should type the corresponding character--the one whose binding is
  819. that alternative.
  820.    This way of using menus in an Emacs-like editor was inspired by the
  821. Hierarkey system.
  822.  - Variable: menu-prompt-more-char
  823.      This variable specifies the character to use to ask to see the
  824.      next line of a menu.  Its initial value is 32, the code for SPC.
  825. File: elisp,  Node: Menu Example,  Next: Menu Bar,  Prev: Keyboard Menus,  Up: Menu Keymaps
  826. Menu Example
  827. ------------
  828.    Here is a simple example of how to set up a menu for mouse use.
  829.      (defvar my-menu-map
  830.        (make-sparse-keymap "Key Commands <==> Functions"))
  831.      (fset 'help-for-keys my-menu-map)
  832.      
  833.      (define-key my-menu-map [bindings]
  834.        '("List all keystroke commands" . describe-bindings))
  835.      (define-key my-menu-map [key]
  836.        '("Describe key briefly" . describe-key-briefly))
  837.      (define-key my-menu-map [key-verbose]
  838.        '("Describe key verbose" . describe-key))
  839.      (define-key my-menu-map [function]
  840.        '("Describe Lisp function" . describe-function))
  841.      (define-key my-menu-map [where-is]
  842.        '("Where is this command" . where-is))
  843.      
  844.      (define-key global-map [C-S-down-mouse-1] 'help-for-keys)
  845.    The symbols used in the key sequences bound in the menu are
  846. fictitious "function keys"; they don't appear on the keyboard, but that
  847. doesn't stop you from using them in the menu.  Their names were chosen
  848. to be mnemonic, because they show up in the output of `where-is' and
  849. `apropos' to identify the corresponding menu items.
  850.    However, if you want the menu to be usable from the keyboard as well,
  851. you must bind real ASCII characters as well as fictitious function keys.
  852. File: elisp,  Node: Menu Bar,  Next: Modifying Menus,  Prev: Menu Example,  Up: Menu Keymaps
  853. The Menu Bar
  854. ------------
  855.    Most window systems allow each frame to have a "menu bar"--a
  856. permanently displayed menu stretching horizontally across the top of the
  857. frame.  The items of the menu bar are the subcommands of the fake
  858. "function key" `menu-bar', as defined by all the active keymaps.
  859.    To add an item to the menu bar, invent a fake "function key" of your
  860. own (let's call it KEY), and make a binding for the key sequence
  861. `[menu-bar KEY]'.  Most often, the binding is a menu keymap, so that
  862. pressing a button on the menu bar item leads to another menu.
  863.    When more than one active keymap defines the same fake function key
  864. for the menu bar, the item appears just once.  If the user clicks on
  865. that menu bar item, it brings up a single, combined submenu containing
  866. all the subcommands of that item--the global subcommands, the local
  867. subcommands, and the minor mode subcommands, all together.
  868.    The variable `overriding-local-map' is normally ignored when
  869. determining the menu bar contents.  That is, the menu bar is computed
  870. from the keymaps that would be active if `overriding-local-map' were
  871. `nil'.  *Note Active Keymaps::.
  872.    In order for a frame to display a menu bar, its `menu-bar-lines'
  873. parameter must be greater than zero.  Emacs uses just one line for the
  874. menu bar itself; if you specify more than one line, the other lines
  875. serve to separate the menu bar from the windows in the frame.  We
  876. recommend 1 or 2 as the value of `menu-bar-lines'.  *Note X Frame
  877. Parameters::.
  878.    Here's an example of setting up a menu bar item:
  879.      (modify-frame-parameters (selected-frame)
  880.                               '((menu-bar-lines . 2)))
  881.      
  882.      ;; Make a menu keymap (with a prompt string)
  883.      ;; and make it the menu bar item's definition.
  884.      (define-key global-map [menu-bar words]
  885.        (cons "Words" (make-sparse-keymap "Words")))
  886.      
  887.      ;; Define specific subcommands in the item's menu.
  888.      (define-key global-map
  889.        [menu-bar words forward]
  890.        '("Forward word" . forward-word))
  891.      (define-key global-map
  892.        [menu-bar words backward]
  893.        '("Backward word" . backward-word))
  894.    A local keymap can cancel a menu bar item made by the global keymap
  895. by rebinding the same fake function key with `undefined' as the
  896. binding.  For example, this is how Dired suppresses the `Edit' menu bar
  897. item:
  898.      (define-key dired-mode-map [menu-bar edit] 'undefined)
  899. `edit' is the fake function key used by the global map for the `Edit'
  900. menu bar item.  The main reason to suppress a global menu bar item is
  901. to regain space for mode-specific items.
  902.  - Variable: menu-bar-final-items
  903.      Normally the menu bar shows global items followed by items defined
  904.      by the local maps.
  905.      This variable holds a list of fake function keys for items to
  906.      display at the end of the menu bar rather than in normal sequence.
  907.      The default value is `(help)'; thus, the `Help' menu item
  908.      normally appears at the end of the menu bar, following local menu
  909.      items.
  910.  - Variable: menu-bar-update-hook
  911.      This normal hook is run whenever the user clicks on the menu bar,
  912.      before displaying a submenu.  You can use it to update submenus
  913.      whose contents should vary.
  914.